In [28]:
    
s1 = 'This is a test string'
# [ord(x) for x in s1] This list comprehension gives us a list of integer values for each character
# join takes a sequence of str() and joins them
' '.join([str(ord(x)) for x in s1])
    
    Out[28]:
In [45]:
    
' '.join([format(ord(x)) for x in s1])
    
    Out[45]:
In [49]:
    
' '.join([format(ord(x), 'b') for x in s1])
    
    Out[49]:
If we want it to be 8 bits long
In [50]:
    
' '.join([format(ord(x), 'b').zfill(8) for x in s1])
    
    Out[50]:
In [ ]:
    
    
converting each character into its unicode ordinal value then format that result into a hex while joining each character into a string thats space seperated each value
In [48]:
    
' '.join([format(ord(x), 'x') for x in s1])
    
    Out[48]:
In [51]:
    
' '.join([format(ord(x), 'o') for x in s1])
    
    Out[51]:
In [ ]:
    
    
In [26]:
    
ord?
    
In [27]:
    
# This is an integer value
ord('T')
    
    Out[27]:
In [29]:
    
hex(16)
    
    Out[29]:
In [ ]:
    
    
In [30]:
    
chr?
    
In [33]:
    
chr(84)
    
    Out[33]:
In [1]:
    
bin?
    
With int you specify the base of the string, not the base your trying to convert to converts everything to ints
In [38]:
    
int('0xDEADBEEF', 16)
    
    Out[38]:
In [39]:
    
int('DEADBEEF', 16)
    
    Out[39]:
In [40]:
    
int('DEADBEEF')
    
    
In [41]:
    
int('0oDEADBEEF', 16)
    
    
In [55]:
    
chr(int('54', 16))
    
    Out[55]:
In [56]:
    
chr(int('124', 8))
    
    Out[56]:
In [57]:
    
chr(int('01010100', 2))
    
    Out[57]:
In [32]:
    
format?
    
In [34]:
    
format(x, 'x')
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]:
    
    
In [ ]: